<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">
    <h:head>
        <title>fckeditor_demo</title>

        <style>
            .column {
                width: 410px;
                vertical-align: top;
            }
            .rowc{
                text-align: right
            }
            .center{
                text-align:center;
                align:center;
            }
        </style>
        <link href="#{fileUploadAnnounceBean.fckurl}/fckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="#{fileUploadAnnounceBean.fckurl}/fckeditor/fckeditor.js"></script>
        <script type="text/javascript">

            //初始化fckeditor
            window.onload = function()
            {
                var sBasePath = "#{fileUploadAnnounceBean.fckurl}/fckeditor/";
                var oFCKeditor = new FCKeditor('form:content');
                oFCKeditor.BasePath = sBasePath;
                oFCKeditor.ReplaceTextarea();

            }
        </script>
    </h:head>
    <h:form id="form">
        <rich:panel header="公告编辑" styleClass="content-hight">
            类别： <h:outputText  value="#{announceUpdateBean.type.name}"/><hr/>
            <h:panelGroup styleClass="center" layout="block">
                *标题：<h:inputText value="#{announceUpdateBean.announce.title}" size="40"/><br/>
            </h:panelGroup>
            <br/>
            <h:panelGrid columns="2" columnClasses="top,top">
                 摘要：
                <h:panelGrid columns="4" columnClasses="top,bottom,bottom,bottom">
                    <h:inputTextarea  id="outline" rows="5" cols="80"
                                      value="#{announceUpdateBean.announce.outline}"
                                      style="width: 200px; height: 70px" />
                    <h:selectBooleanCheckbox  value="#{announceUpdateBean.imp}"/>重要公告
                    <a4j:commandLink value="上传附件" onclick="#{rich:component('fujianPopPanel')}.show();"
                                 style="margin-left: 20px;"/>
                </h:panelGrid>

            <p/>
            <h:inputTextarea id="content" rows="15" cols="100"
                              value="#{announceUpdateBean.announce.content}"/>
            <br/>
            <p/>
            <h:panelGroup layout="block">
                <h:commandButton value="保存" action="#{announceUpdateBean.publish}"></h:commandButton>
                <h:commandButton value="预览" action="#{announceUpdateBean.preview}" rendered="false"></h:commandButton>
                <h:commandButton value="返回" action="#{announceUpdateBean.reselect}"></h:commandButton>
            </h:panelGroup>
            </h:panelGrid>
        </rich:panel>
    </h:form>    

    <rich:popupPanel id="fujianPopPanel" minWidth="500" autosized="true">
        <f:facet name="header">部门</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#"
                          onclick="#{rich:component('fujianPopPanel')}.hide();
                return false;">关闭</h:outputLink>
        </f:facet>
        <rich:panel>
            <h:form>
                <h:panelGroup>
                    附件上传：
                    <h:panelGrid columns="2" columnClasses="top,top">
                        <rich:fileUpload fileUploadListener="#{fileUploadAnnounceBean.listener2}"
                                         maxFilesQuantity="#{fileUploadAnnounceBean.uploadsAvailable}"
                                         style="width: 300px;"
                                         id="upload">
                            <a4j:ajax event="uploadcomplete" render="info,errmessage" />
                        </rich:fileUpload>
                        <h:panelGroup id="info">
                            <div style="max-height: 400px;overflow: auto">
                                <rich:panel bodyClass="info">
                                    <f:facet name="header">
                                        <h:outputText value="上传成功后的文件信息" />
                                    </f:facet>
                                    <h:outputText value="当前并未上传.."
                                                  rendered="#{fileUploadAnnounceBean.size==0}" />
                                    <rich:dataGrid columns="1" value="#{fileUploadAnnounceBean.files}"
                                                   var="file" rowKeyVar="row">
                                        <rich:panel bodyClass="rich-laguna-panel-no-header">
                                            <h:panelGrid columns="2">
                                                <a4j:mediaOutput element="img" mimeType="#{file.mime}"
                                                                 createContent="#{fileUploadAnnounceBean.paint}" value="#{row}"
                                                                 style="width:100px; height:100px;" cacheable="false">
                                                    <f:param value="#{fileUploadAnnounceBean.timeStamp}" name="time"/>
                                                </a4j:mediaOutput>
                                                <h:panelGrid columns="2">
                                                    <h:outputText value="文件名:" />
                                                    <h:outputText value="#{file.name}" />
                                                    <h:outputText value="文件大小(bytes):" />
                                                    <h:outputText value="#{file.length}" />
                                                </h:panelGrid>
                                            </h:panelGrid>
                                        </rich:panel>
                                    </rich:dataGrid>
                                </rich:panel>
                            </div>
                            <a4j:commandButton action="#{fileUploadAnnounceBean.clearUploadData}"
                                               render="info, upload" value="清除上传的文件信息"
                                               rendered="#{fileUploadAnnounceBean.size>0}" />
                        </h:panelGroup>
                    </h:panelGrid>
                </h:panelGroup>
            </h:form>
        </rich:panel>
    </rich:popupPanel>
</html>